package com.gxa.business.controller;

import com.gxa.business.dto.BusinessDTO;
import com.gxa.business.dto.EditBusinessDTO;
import com.gxa.business.service.BusinessService;
import com.gxa.common.base.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/business")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    /**
     * 新建商海
     * @param businessDTO
     * @return
     */
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public RespResult create(@RequestBody BusinessDTO businessDTO){
        return businessService.insertBusinessInfo(businessDTO);
    }

    /**
     * 编辑商海
     * @param editBusinessDTO
     * @return
     */
    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    public RespResult edit(@RequestBody EditBusinessDTO editBusinessDTO){
        return businessService.editBusinessInfo(editBusinessDTO);
    }

    /**
     * 修改商海状态--下架
     * @param code
     * @return
     */
    @RequestMapping(value = "/updateStatus",method = RequestMethod.POST)
    public RespResult updateStatus(Integer code){
        return businessService.updateStatus(code);
    }

    /**
     * 详情
     * @param code
     * @return
     */
    @RequestMapping(value = "/detail",method = RequestMethod.GET)
    public RespResult selectBusinessInfoByCode(Integer code){
        return businessService.selectBusinessInfoByCode(code);
    }

    /**
     * 查询所有商海信息
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/queryAllBusinessInfo",method = RequestMethod.GET)
    public RespResult queryAllBusinessInfo(int currentPage, int pageSize){
        return businessService.queryAllBusinessInfo(currentPage,pageSize);
    }

    /**
     * 按照国家地区查询商海信息
     * @param country
     * @return
     */
    @RequestMapping(value = "queryAllBusinessInfoByCountry",method = RequestMethod.GET)
    public RespResult queryAllBusinessInfoByCountry(int currentPage, int pageSize,String country){
        return businessService.queryAllBusinessInfoByCountry(currentPage,pageSize,country);
    }


}
